package com.aydqyy.springbootstart.controller;

import com.aydqyy.springbootstart.common.exception.Result;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

import static com.aydqyy.springbootstart.common.exception.Result.success;

@RestController
public class FileUploadController {

    @PostMapping("/upload")
    public Result<String> upload(@RequestPart(name="file") MultipartFile file) throws IOException {//把文件的内容存储到么地磁盘上
        String originalFilename = file.getOriginalFilename();
        file.transferTo(new File("d:\\tempfiles\\" + originalFilename));
        return Result.success("上传成功");
    }
}